package com.adbj.sychronizedtest;

public class SynchronizedTest implements Runnable{
    int count=0;
    //synchronized修饰实例方法（普通方法）  锁实例对象
    @Override
    public synchronized void run() {
        for (int i = 0; i <5 ; i++) {
            //count++;
            System.out.println(Thread.currentThread().getName()+":"+count++);

        }
    }

    public static void main(String[] args) {
        SynchronizedTest s=new SynchronizedTest();
        Thread thread1=new Thread(s,"thread1");
        Thread thread2=new Thread(s,"thread2");
        thread1.start();
        thread2.start();
    }

}
